home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4217 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: inforamp.net!ts44-07
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Please help!
  5. Date: Fri, 02 Feb 96 18:33:00 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4etl2u$7s1@sam.inforamp.net>
  8. References: <4ehtt2$313@fang.dsto.defence.gov.au>
  9. NNTP-Posting-Host: ts44-07.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4ehtt2$313@fang.dsto.defence.gov.au>,
  13.    yenh@MRD.SRL.dsto.gov.au (Hung Yen) wrote:
  14. >Please take a look at this source code:
  15. >
  16. >#include <Xm/List.h>
  17. >#include <stdio.h>
  18. >/* Function to sort an array of integers into ascending order */
  19. >void sort (a,n)
  20. >int a[];
  21. >int n;
  22. >{
  23. >  int i,j,temp;
  24. >  for (i=0; i < n -1; ++i)
  25. >    for (j=i+1; j<n; ++j)
  26. >      if (a[i] > a[j])
  27. >        {
  28. >           temp = a[i];
  29. >           a[i] = a[j];
  30. >           a[j] = temp;
  31. >         }
  32. >
  33. >}
  34. >
  35. >int get_first_selected_plans(w,selected_count)
  36. >Widget w;
  37. >int selected_count;
  38. >{
  39. >  int **position_list;
  40. >  int *position_count, first_selected_plan_number;
  41. >  Boolean Ok;
  42. >
  43. >  if (!w){
  44. >    return 0;
  45. >  }
  46. >  Ok = XmListGetSelectedPos(w,position_list,position_count);
  47. >  sort(position_list,&position_count);
  48. >  first_selected_plan_number = position_list[1];
  49. Right here.
  50. position_list[1] is a pointer to an integer
  51. and first_selected_plan_number is an integer.
  52. I could be wrong, but that's my read.
  53. >  return first_selected_plan_number;
  54. >}
  55. >
  56. >This is my first try at C programming, so any help will be greatly 
  57. appreciate.
  58. >
  59. >hung
  60. >
  61. >
  62.